import React, { Component } from 'react';
import CustomBreadcrumb from '../../components/CustomBreadcrumb';
import AddChannelForm from './components/AddChannelForm';
import { hashHistory } from 'react-router';
import { ChannelService } from '../../services'

export default class AddChannel extends Component {
  static displayName = 'AddChannel';

  constructor(props) {
    super(props);
    this.state = {};
  }

  onSubmit = async(data) =>{
    await ChannelService.save(data)
    hashHistory.push('/channel/list')
    return true
  }

  render() {
    const breadcrumb = [
      { text: '渠道管理', link: '#/channel/list' },
      { text: '新增渠道', link: '#/channel/add' },
    ];
    return (
      <div className="addchannel-page">
        <CustomBreadcrumb dataSource={breadcrumb} />
        <AddChannelForm onSubmit={this.onSubmit}/>
      </div>
    );
  }
}
